// const { textStride } = require("XrFrame/components/text/Text");

// diaoyu/pages/diaodian/catchFish/catchFish.js
var $ = getApp();
// methods = require("../../methods.js");
Page({

    /**
     * 页面的初始数据
     */
    data: {
      list:[],
      id:0,
      id2:0,
      yuhuototal:0,
      huiyuprice:'',
      weight:'',
      info:[],
      countArr:[],
      
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
      console.log('鱼获重量opt111',options)
      let pid = options.id
      let ppid = options.id2
      this.setData({id:pid,id2:ppid});
      this.getList()
    },


    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },
    // inputChange1(e){
    //   this.setData({
    //     number:e.detail.value
    //   })
    //   console.log('999',e.detail.value,this.data.number)
    // },
    inputChange(e){
      console.log('输入鱼获111',e.currentTarget.dataset.id)
      const number = e.currentTarget.dataset.id
      const weight = e.
      this.setData({
        weight:e.detail.value
      })
      console.log('999',e.detail.value,this.data.weight)
    },
   getList(){
    let that = this
    $.post('/yuxun/weightdata',{id:that.data.id},function(res){
      console.log('鱼获列表11',res)
      
      that.setData({
        list:res.data,
        fangyu:res.fangyu,
        huiyuprice:res.huiyuprice
      })
      console.log('list33',that.data.list)
    })
   },
  //  确定鱼获重量
  edit(e){
      // const obj = {}
      console.log('eee111',e)
      const number = e.currentTarget.dataset.id
      
      wx.showModal({
        editable:true,//显示输入框
        placeholderText:'请输入鱼获重量（斤）',//显示输入框提示信息
        success: res => {
          if (res.confirm) { //点击了确认
            console.log(res.content)//用户输入的值
            const obj = {number:number,weight:res.content}
            const num = this.data.huiyuprice * res.content
            const arr = this.data.info
            const countArr = this.data.countArr
           
           
            arr.push(obj)
            countArr.push(num)
            this.setData({
              info:arr,
              countArr:countArr,
              yuhuototal:this.data.yuhuototal + Number(res.content)
            })
          } else {
            console.log('用户点击了取消')
          }
        }
      })
  },
  // 发布成绩
  pub(){
    let that = this
    wx.showModal({
      title: '提示',
      content: '确定发布成绩吗',
      success (res) {
        if (res.confirm) {
          console.log('用户点击确定',that.data.id,that.data.id2,that.data.info)
          $.post('yuxun/addweight',{fangdiao_id:that.data.id,diaochang_id:that.data.id2,info:that.data.info},function(res){
            wx.showToast({
              title: res.msg,
              icon:'success', 
              duration:2000
            })
            setTimeout(function() {
              console.log("2 seconds have passed.");
              $.goto('/diaoyu/pages/diaodian/my')
            }, 1000);
            
          })
        } else if (res.cancel) {
          console.log('用户点击取消')
        }
      }
    })
  },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

})